<template>
	<view>
		<Loading ref="load"></Loading>
	</view>
</template>

<script>
	export default {
		data() {
			return {}
		},
		onLoad() {
			this.checkLoginState();
		},
		methods: {
			//检查登陆状态
			checkLoginState() {
				let _this=this;
				let _userId=uni.getStorageSync("userId");
				this.$refs.load.initLoading({
					loadType: 0
				}).then(res => {
					uni.checkSession({
						success(res) {
							if (res.errMsg == "checkSession:ok"&&_userId) {
								_this.jumpUrl('/pages/index/index');
							} else {
								_this.jumpUrl('/pages/login/login');
							}
						},
						fail(err) {
							_this.jumpUrl('/pages/login/login');
						}
					})
					this.$refs.load.getLoadingData({});
				})
			},
			jumpUrl(url){
				uni.reLaunch({
					url
				})
			}
		}
	}
</script>

<style>

</style>
